<template>
    <view class="px-[42rpx] pt-[52rpx] ">
        <view class="flex justify-center">
            <image src="/static/images/img/lfangz.png" class="w-[368rpx] h-[368rpx]"></image>
        </view>

        <view class="h-[80rpx] mt-[10rpx] flex justify-center mx-[56rpx]">
            <up-input placeholder="请输入邀请码" v-model="code" border="none" shape="circle" :customStyle="{
                backgroundColor: '#FFFFFF',
                height: '40px',
                padding: '12rpx',
                paddingLeft: '42rpx',
                width: '554rpx',
                fontSize: '25rpx',
                height: '100rpx'
            }"></up-input>
        </view>
        <view v-if="showText" class="text-[#FF0000] text-[28rpx] font-[PingFang SC] mt-[42rpx] flex justify-center">{{rtesmsg}}</view>
        <view @click="joinfamilys" class="w-[538rpx] h-[108rpx] text-[#000000] fixed bottom-[80rpx] " style=" border-radius: 400rpx;left: 50%; transform: translateX(-50%) ">
            <image src="@/static/images/img/qd.png" class="w-[538rpx] h-[108rpx]"></image>
        </view>
    </view>
</template>
<script setup>
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app'
import { joinFamily } from '@/api/home.js'
const code = ref('');
const rtesmsg = ref('');
// 控制文字显示
const showText = ref(false);
const joinfamilys = () => {
    const params = {
        code: code.value
    }
    joinFamily(params).then(res => {
    if (res.code === 200) {
        console.log(res, '加入家庭成功');
        uni.navigateTo({
            url: '/pages_cw/homemanagement/homemanagement?tab=1'
        });
    }else {
        showText.value = true;
        rtesmsg.value = res.msg;
    }
    })
}


</script>
<style scoped lang="scss"></style>